{% extends 'home.html' %}


{% block content %}
    <a href="{% url 'book_add' %}" class="btn btn-success">添加</a>
    <br>
    <table class="table table-hover table-striped table-bordered">
        <thead>
            <tr>
                <th>ID</th>
                <th>序号</th>
                <th>书名</th>
                <th>价格</th>
                <th>出版日期</th>
                <th>出版社</th>
                <th>作者</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for book_obj in book_queryset %}
                <tr>
                    <td>{{ book_obj.pk }}</td>
                    <td>{{ forloop.counter }}</td>
                    <td>{{ book_obj.title }}</td>
                    <td>{{ book_obj.price }}</td>
                    <td>{{ book_obj.publish_date | date:'Y-m-d' }}</td>
                    <td>{{ book_obj.publish.name }}</td>
                    <td>{{ book_obj.author_name }}</td>
                    <td>
                        <a href="{% url 'book_edit' book_obj.pk %}" class="btn btn-primary">编辑</a>
                        <a href="{% url 'book_delete' book_obj.pk %}" class="btn btn-danger">删除</a>
                    </td>
                </tr>
            {% endfor %}

        </tbody>
    </table>

{% endblock %}